<template>
  <div>
    <vcu-chart-pie
      :beforeDataLoad="beforeDataLoad"
      :height="800"
      :legend="legend"
      :title="title"
      :loadOptions="chart.loadOptions"
      :minShowLabelAngle="100"
      :settings="chart.settingsForPie"
      ref="pie"
    ></vcu-chart-pie>
  </div>
</template>

<script>
export default {
  name: "basic",
  data() {
    return {
      title: { text: "药品出库中标药品统计", left: "center" },
      legend: {
        orient: "vertical",
        right: 20,
        // formatter: (name) => {
        //   let [data] = this.chart.data.filter(item => {
        //     return item.TJXMMC === name
        //   })
        //   return `${name} ${data.XYLSJE}`;
        // },
      },
      chart: {
        data: [],
        loadOptions: {
          chartUrl: "dataq/api/chart/ykcxDetailInfoForYPRKTJ",
          dataUrl: "dataq/api/page/ykcxDetailInfoForYPRKTJ",
          formData: {
            YPLBBH: "0",
            RCLXBH: "",
            statusVal: "0",
            startDate: "20220126",
            endDate: "20220126",
            startTime: "2022012600:00:00",
            endTime: "2022012623:59:59",
            zbItemVal: "0",
            jcItemVal: "0",
            zfdjItemVal: "0",
            gsSFXSPFJ: "N",
            gsYYGXH: "N",
            YK_RKTJ_XY: "Y",
            YK_RKTJ_ZCY: "Y",
            YK_RKTJ_CY: "Y",
            YK_TKTHSFHBCRK: "N",
            gsUserDeptBMXZ: "6",
            YKBMBH: "193",
          },
        },
        settingsForPie: {
          label: {
            show: true,
            fontSize: "12",
            fontWeight: "bold",
            formatter: "{b}  {d}%",
          },
        },
      },
    };
  },
  mounted() {
    this.$refs.pie.getChartData();
  },
  methods: {
    beforeDataLoad(data) {
      this.chart.data = data.filter((item) => {
        return item.BMMC00 != "总计:";
      });
      return this.chart.data;
    },
  },
};
</script>
